package org.example.lp.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {

    @Bean
    public DirectExchange demoDirectExchange() {
        return new DirectExchange(MQConstance.DEMO_DIRECT_EXCHANGE, true, false);
    }

    @Bean
    public Queue demoQueue() {
        return new Queue(MQConstance.DEMO_QUEUE, true);
    }

    @Bean
    public Binding demoBinding() {
        return BindingBuilder.bind(demoQueue()).to(demoDirectExchange())
                .with(MQConstance.DEMO_QUEUE);
    }

}
